define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'manage/checkpoint/index' + location.search,
                    add_url: 'manage/checkpoint/add',
                    edit_url: 'manage/checkpoint/edit',
                    del_url: 'manage/checkpoint/del',
                    multi_url: 'manage/checkpoint/multi',
                    import_url: 'manage/checkpoint/import',
                    table: 'checkpoint',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                searchFormVisible:true,
                search:false,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'),operate: false},
                        {field: 'checkpoint', title: __('Checkpoint'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
                        {field: 'position_id', title: __('Position'),searchList:$.getJSON('manage/checkpoint/searchcategory'),visible:false},
                        {field: 'position', title: __('Position'),operate: false},
                        {field: 'pointpic', title: __('Pointpic'), formatter:Table.api.formatter.image,events: Table.api.events.image,operate: false},
                        {field: 'qrcode', title: __('Qrcode'), formatter:Table.api.formatter.image,events: Table.api.events.image,operate: false},
                        {field: 'status', title: __('Status'),formatter: Table.api.formatter.status, searchList: {1: __('Status 1'), '2': __('Status 2')},operate: false},
                        {field: 'is_pic', title: __('Is_pic'),formatter: Table.api.formatter.status, searchList: {1: __('Is_pic 1'), '2': __('Is_pic 2')},operate: false},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false,operate: false},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});
